package cn.zr.aitool.activitys;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;

import cn.zr.aitool.R;
import cn.zr.aitool.bean.TextContent;

public class TextActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);
        String  result = getIntent().getStringExtra("content");
        Log.i("infoPopText",result);
        Gson gson =new Gson();
        final TextContent tc = gson.fromJson(result, TextContent.class);
        TextView view = findViewById(R.id.text);
        view.setText(tc.getWords());
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ClipboardManager myClipboard = (ClipboardManager)TextActivity.this.getSystemService(TextActivity.CLIPBOARD_SERVICE);
                ClipData myClip = ClipData.newPlainText("text", tc.getWords());
                myClipboard.setPrimaryClip(myClip);
                Toast.makeText(TextActivity.this,"复制成功",Toast.LENGTH_SHORT).show();
            }
        });
    }
}
